package com.sondon.mayi.adapter;

import java.util.ArrayList;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import com.sondon.mayi.entity.AddressInfo;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * 
 * @Project : Fruit
 * @Package : com.sondon.mayi.adapter
 * @Class : AddressListAdapter
 * @Author : 蔡文锋
 * @DateTime：2015年6月30日 下午8:38:57
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : { 地址列表适配器 }
 *
 */
@EBean
public class AddressListAdapter extends BaseAdapter {
	@RootContext
	Context context;
	ArrayList<AddressInfo> addressinfos=new ArrayList<AddressInfo>();
	
	public void setDatas(ArrayList<AddressInfo> addressinfos){
		this.addressinfos.clear();
		if(addressinfos!=null){
			this.addressinfos.addAll(addressinfos);
		}
		notifyDataSetChanged();
	}
	
	public ArrayList<AddressInfo> GetDatas(){
		return this.addressinfos;
	}
	
	@Override
	public int getCount() {
		return addressinfos.size();
	}

	@Override
	public Object getItem(int position) {
		return addressinfos.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup person) {
		AddressList_Item item;
		if(convertView==null){
			item=AddressList_Item_.build(context);
		}else{
			item=(AddressList_Item) convertView;
		}
		item.bindData(addressinfos.get(position),position);
		return item;
	}

}
